import pymysql
DBHOST='localhost'
DBUSER='root'
PASSWORD='kongxingli2002'
DBNAME='supermarket'
try:
    db=pymysql.connect(host=DBHOST,user=DBUSER,password=PASSWORD,database=DBNAME)
    print("ook")
    cur=db.cursor()
   #cur.execute('DROP TABLE IF EXISTS staff')#删除表
   ##建表
   #sql='CREATE TABLE staff(Name char(20) not null,Email char(20),Age int)'
    sql='INSERT INTO student(Name,Email,Age) VALUE (%s,%s,%s)'
    i=input('名字:')
    j=input('邮箱:')
    k=int(input('年龄:'))
    value=(i,j,k)
    cur.execute(sql,value)
    db.commit()
    print("表ok")
except pymysql.Error as e:
    print('表 not ok'+str(e))
    db.rollback()

db.close()